package proseus.app.meet;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MeetListAdapter extends BaseAdapter {
	int m_layout;
	LayoutInflater m_inflater;
	ArrayList<MeetListItem> m_items;

	public MeetListAdapter(Context context, int layout,
			ArrayList<MeetListItem> items) {
		m_layout = layout;
		m_inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		m_items = items;
	}

	@Override
	public int getCount() {
		return m_items.size();
	}

	@Override
	public Object getItem(int index) {
		return m_items.get(index).m_meet;
	}

	@Override
	public long getItemId(int index) {
		return index;
	}

	@Override
	public View getView(int index, View view, ViewGroup parent) {
		if (view == null) {
			view = m_inflater.inflate(m_layout, parent, false);
		}

		TextView tvMeet = (TextView) view.findViewById(R.id.tvMeet);
		tvMeet.setText(m_items.get(index).m_meet);

		TextView tvDate = (TextView) view.findViewById(R.id.tvDate);
		tvDate.setText(m_items.get(index).m_date);

		TextView tvWhere = (TextView) view.findViewById(R.id.tvWhere);
		tvWhere.setText(m_items.get(index).m_where);

		return view;
	}
}
